Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
cldr-language-country
Advanced tools
A small utility to get CLDR, country code (cc) and language code (lc) data.
Tiny util that maps 2-character language codes (lc) and country codes (cc) to CLDR locale data. Especially useful for generating search queries.
npm i cldr-language-country
function | parameters | returns |
---|---|---|
generateData | none | Data for all locales |
getLocales | none | Array of all locales (string) |
getCountries | none | Array of all country data, with name and code |
getLanguages | none | Array of all language data, with name , native , and code |
keyByCC | none | Object containing all data, keyed by country code |
keyByLC | none | Object containing all data, keyed by language code |
getByCC | cc(String) | Array of all data whose country.code matches cc . |
getByLC | lc(String) | Array of all data whose language.code matches lc . |
getByCountryName | name(string) | Array of all data whose country.name matches name . |
getByLanguage | name(String) | Array of all data whose language.name matches name . |
getByLocale | locale(String) | Array of all data whose locale matches the provided locale |
getByNativeName | name(String) | Array of all data whose language.name matches name . |
generateData()
import { generateData } from 'cldr-language-country';
const locales = generateData();
Result:
[
{
language: {
code: 'en',
name: 'English',
native: 'English'
},
country: {
code: 'us',
name: 'United States'
},
locale: 'en-US'
}
]
getLocales()
import { getLocales } from 'cldr-language-country';
const locales = getLocales();
Result:
[
'ps-AF', 'fa-AF', 'uz-AF', 'sv-AX', 'sq-AL', 'en-AL', 'ar-DZ',
'fr-DZ', 'en-AS', 'ca-AD', 'en-AD', 'ln-AO', 'pt-AO', 'en-AI',
...continued
]
getCountries()
import { getCountries } from 'cldr-language-country';
const countries = countries();
Result:
[
{ code: 'AF', name: 'Afghanistan' },
{ code: 'AX', name: 'Åland Islands' },
{ code: 'AL', name: 'Albania' },
{ code: 'DZ', name: 'Algeria' },
{ code: 'AS', name: 'American Samoa' },
...continued
]
getLanguages()
import { getLanguages } from 'cldr-language-country';
const languages = getLanguages();
Result:
[
{ code: 'aa', name: 'Afar', native: 'Afar' },
{ code: 'ab', name: 'Abkhazian', native: 'Аҧсуа' },
{ code: 'af', name: 'Afrikaans', native: 'Afrikaans' },
{ code: 'ak', name: 'Akan', native: 'Akana' },
{ code: 'am', name: 'Amharic', native: 'አማርኛ' },
...continued
]
keyByCC()
import { keyByCC } from 'cldr-language-country';
const locales = keyByCC();
Result:
{
'CA': [
{
language: {
code: 'en',
name: 'English',
native: 'English'
},
country: {
code: 'CA',
name: 'Canada'
},
locale: 'en-CA'
},
{
language: {
code: 'fr',
name: 'French',
native: 'Français'
},
country: {
code: 'CA',
name: 'Canada'
},
locale: 'fr-CA'
}
]
}
keyByLC()
import { keyByLC } from 'cldr-language-country';
const locales = keyByLC();
Result:
{
'en': [
{
language: {
code: 'en',
name: 'English',
native: 'English'
},
country: {
code: 'AE',
name: 'United Arab Emirates'
},
locale: 'en-AE'
},
{
language: {
code: 'en',
name: 'English',
native: 'English'
},
country: {
code: 'AG',
name: 'Antigua and Barbuda'
},
locale: 'en-AG'
},
...continued
]
}
getByCC(cc)
import { getByCC } from 'cldr-language-country';
const locales = getByCC('US');
Result:
[
{
language: { code: 'en', name: 'English', native: 'English' },
country: { code: 'US', name: 'United States' },
locale: 'en-US'
},
{
language: { code: 'es', name: 'Spanish', native: 'Español' },
country: { code: 'US', name: 'United States' },
locale: 'es-US'
}
]
getByLC(lc)
import { getByLC } from 'cldr-language-country';
const locales = getByLC('zh');
Result:
[
{
language: { code: 'zh', name: 'Chinese', native: '中文' },
country: { code: 'CN', name: 'China' },
locale: 'zh-CN'
},
{
language: { code: 'zh', name: 'Chinese', native: '中文' },
country: { code: 'CN', name: 'China' },
locale: 'zh-CN'
},
...continued
]
getByCountryName(name)
import { getByCountryName } from 'cldr-language-country';
const locales = getByCountryName('Japan');
Result:
[
{
language: { code: 'en', name: 'English', native: 'English' },
country: { code: 'JP', name: 'Japan' },
locale: 'en-JP'
},
{
language: { code: 'ja', name: 'Japanese', native: '日本語' },
country: { code: 'JP', name: 'Japan' },
locale: 'ja-JP'
}
]
getByLanguageName(name)
import { getByLanguageName } from 'cldr-language-country';
const locales = getByLanguageName('Tagalog');
Result:
[
{
language: { code: 'tl', name: 'Tagalog / Filipino', native: 'Tagalog' },
country: { code: 'PH', name: 'Philippines' },
locale: 'tl-PH'
}
]
getByLocale(locale)
import { getByLocale } from 'cldr-language-country';
const locales = getByLocale('km-KH');
Result:
[
{
language: { code: 'km', name: 'Khmer', native: 'ភាសាខ្មែរ' },
country: { code: 'KH', name: 'Cambodia' },
locale: 'km-KH'
}
]
getByNativeName(name)
import { getByNativeName } from 'cldr-language-country';
const locales = getByNativeName('فارسی');
Result:
[
{
language: { code: 'fa', name: 'Persian', native: 'فارسی', rtl: 1 },
country: { code: 'AF', name: 'Afghanistan' },
locale: 'fa-AF'
},
{
language: { code: 'fa', name: 'Persian', native: 'فارسی', rtl: 1 },
country: { code: 'IR', name: 'Iran, Islamic Republic of' },
locale: 'fa-IR'
}
]
FAQs
A small utility to get CLDR, country code (cc) and language code (lc) data.
We found that cldr-language-country demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.